Add Navitrak DNA format, from Tim Zickus, tez@zickus.com
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 1 Oct 2002 21:39:43 +0000 (21:39 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 1 Oct 2002 21:39:43 +0000 (21:39 +0000)
gpsbabel/Makefile
gpsbabel/README
gpsbabel/dna.c [new file with mode: 0644]
gpsbabel/reference/dnatest.txt [new file with mode: 0644]
gpsbabel/testo
gpsbabel/vecs.c

index 4fb6dfbf2b014ec57393b394a4f7159512525135..e7b6dac98a39d550ba3964eb5aeef4cdebf32fef 100644 (file)
@@ -2,7 +2,7 @@ CFLAGS=-g -Icoldsync
 
 FMTS=magproto.o gpx.o geo.o gpsman.o mapsend.o mapsource.o \
        gpsutil.o tiger.o pcx.o csv.o cetus.o gpspilot.o magnav.o \
-       psp.o mxf.o holux.o garmin.o ozi.o
+       psp.o mxf.o holux.o garmin.o ozi.o dna.o
 
 JEEPS=jeeps/gpsapp.o jeeps/gpscom.o jeeps/gpsfmt.o jeeps/gpsinput.o \
        jeeps/gpsmath.o jeeps/gpsmem.o  \
@@ -24,6 +24,7 @@ clean:
 
 cetus.o: cetus.c defs.h queue.h coldsync/palm.h coldsync/pdb.h
 csv.o: csv.c defs.h queue.h csv_util.h
+dna.o: dna.c defs.h queue.h csv_util.h
 csv_util.o: csv_util.c defs.h queue.h csv_util.h
 garmin.o: garmin.c defs.h queue.h jeeps/gps.h jeeps/gpsport.h \
   jeeps/gpsserial.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
index 5ce18ef52c9aa2fbc6aeb3a88bce360a94a2b11e..e222bd5a1147b8edb3ef2de545802f37ed358cbf 100644 (file)
@@ -141,6 +141,14 @@ THE FORMATS
         Professional, Take a Hike, and ExpertGPS import/export MFX.
         Contributed by Alex Mottram.
 
+    DNA
+
+       Navitrak DNA marker format - Another CSV format file.
+       This is the format that is compatible with the DNA Desktop
+       import/export command.  Reading the binary Markers.jwp 
+       format directly off the data card is not supported yet.
+       Contributed by Tim Zickus.
+
     OZI
 
         OziExplorer Waypoint Format - Another CSV format file.  Tested
diff --git a/gpsbabel/dna.c b/gpsbabel/dna.c
new file mode 100644 (file)
index 0000000..d4116e9
--- /dev/null
@@ -0,0 +1,162 @@
+/*
+  Comma separated value files for Navitrak DNA waypoints.
+  WPT#,Northing,Easting,Name
+  
+  10/1/02 - t. e. zickus, shamelessly hacked from csv.c, below.
+
+    Copyright (C) 2002 Robert Lipe, robertlipe@usa.net
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+ */
+
+#include "defs.h"
+#include "csv_util.h"
+#include <ctype.h>
+
+static FILE *file_in;
+static FILE *file_out;
+
+#define MYNAME "DNA"
+
+static void
+rd_init(const char *fname)
+{
+       file_in = fopen(fname, "r");
+       if (file_in == NULL) {
+               fatal(MYNAME ": Cannot open %s for reading\n", fname);
+       }
+}
+
+static void
+rd_deinit(void)
+{
+       fclose(file_in);
+}
+
+static void
+wr_init(const char *fname)
+{
+       file_out = fopen(fname, "w");
+       if (file_out == NULL) {
+               fatal(MYNAME ": Cannot open %s for writing\n", fname);
+       }
+}
+
+static void
+wr_deinit(void)
+{
+       fclose(file_out);
+}
+
+static void
+data_read(void)
+{
+       char buff[1024];
+       char *s;
+       int i;
+       waypoint *wpt_tmp;
+       int linecount = 0;
+
+       do {
+               linecount++;
+               memset(&buff, '\0', sizeof(buff));
+               fgets(buff, sizeof(buff), file_in);
+                 
+               if (strlen(buff)) {
+
+                   wpt_tmp = xcalloc(sizeof(*wpt_tmp), 1);
+                   s = buff;
+
+                   /* data delimited by commas, not enclosed */
+                   s = csv_lineparse(s, ",", "", linecount);
+
+                   i = 0;
+
+               while (s) {
+                       switch (i) {
+                       case 0: // WPT #, skip.
+                         break;
+                       case 1:
+                               wpt_tmp->position.latitude.degrees = atof(s);
+                               break;
+                       case 2:
+                               wpt_tmp->position.longitude.degrees = atof(s);
+                               break;
+                       case 3:
+                               wpt_tmp->description = csv_stringtrim(s, " ");
+                               break;
+                       default:
+                               fprintf (stderr, "%s: Warning: unmapped data fields on line %d.\n", 
+                                       MYNAME, linecount);
+                               break;
+                       }
+                       i++;
+
+                       s = csv_lineparse(NULL, ",", "", linecount);
+               }
+           
+               wpt_tmp->creation_time = time(NULL);
+               
+               /* We'll make up our own shortname. */
+               wpt_tmp->shortname = mkshort(wpt_tmp->description);
+               
+               waypt_add(wpt_tmp);
+
+       } else {
+               /* empty line */
+       }
+
+    } while (!feof(file_in));
+}
+
+static void
+dna_waypt_pr(const waypoint *wpt)
+{
+       double lon,lat;
+       char * description = NULL;
+       static int wpt_num = 0;
+
+       lon = wpt->position.longitude.degrees;
+       lat = wpt->position.latitude.degrees;
+
+        if (wpt->description) 
+           description = csv_stringclean(wpt->description, ",\"");
+
+       fprintf(file_out, "%d,%08.5f,%08.5f,%s\n",
+               wpt_num++,
+               lat,
+               lon,
+               description);
+               
+       if (description)
+               free (description);
+
+}
+
+static void
+data_write(void)
+{
+       waypt_disp_all(dna_waypt_pr);
+}
+
+ff_vecs_t dna_vecs = {
+       rd_init,
+       wr_init,
+       rd_deinit,
+       wr_deinit,
+       data_read,
+       data_write,
+};
diff --git a/gpsbabel/reference/dnatest.txt b/gpsbabel/reference/dnatest.txt
new file mode 100644 (file)
index 0000000..49bdf22
--- /dev/null
@@ -0,0 +1,16 @@
+0,27.85049,-82.49305,MACDILL
+1,27.84906,-82.49258,MACDILL PK NAIL
+2,27.84604,-82.48745,BEAVER
+3,27.85049,-82.49305,CARTER
+4,27.87861,-82.58639,188 FLHD
+5,27.81962,-82.60658,BRIGHTWATER E
+6,27.82113,-82.60179,BRIGHTWATER D
+7,27.82098,-82.60052,BRIGHTWATER C
+8,27.81919,-82.59823,BRIGHTWATER B AZ MK 2
+9,27.81850,-82.59673,BRIGHTWATER B
+10,27.93168,-82.42910,BRIDGE 2
+11,27.93139,-82.42889,BRIDGE 2 RM 3
+12,27.87694,-82.58806,GANDY RM 2
+13,27.87694,-82.58806,GANDY RM 4
+14,27.93139,-82.42889,BRIDGE 2 RM 4
+15,27.93169,-82.42927,H 261 RESET
index 45762094f2de6ddc49d1c54c4687b054ab17690d..cd5f5f874185e0599adb66544cad907a83e5dcef 100755 (executable)
@@ -67,6 +67,10 @@ diff ${TMPDIR}/mm.gps ${TMPDIR}/gu.wpt
 ${PNAME} -i magellan -f reference/magfile -o magellan -F ${TMPDIR}/magfile
 diff ${TMPDIR}/magfile reference/magfile
 
+# Navitrak DNA marker format
+${PNAME} -i dna -f reference/dnatest.txt -o dna -F ${TMPDIR}/dnatest.txt
+diff ${TMPDIR}/dnatest.txt reference/dnatest.txt
+
 # PSP (PocketStreets 2002 Pushpin (.PSP)) file format
 rm -f ${TMPDIR}/ps.psp ${TMPDIR}/psp.psp
 ${PNAME} -i psp -f reference/ps.psp -o psp -F ${TMPDIR}/psp.psp
index d2adab48749013ddee9335b64c2a7480ab677fce..4cb72c8d5e83ea29373cc7c1ac881bae29c66132 100644 (file)
@@ -45,6 +45,7 @@ extern ff_vecs_t garmin_vecs;
 extern ff_vecs_t mxf_vecs;
 extern ff_vecs_t holux_vecs;
 extern ff_vecs_t ozi_vecs;
+extern ff_vecs_t dna_vecs;
 
 static
 vecs_t vec_list[] = {
@@ -98,6 +99,11 @@ vecs_t vec_list[] = {
                "csv",
                "Comma separated values"
        },
+       {
+               &dna_vecs,
+               "dna",
+               "Navitrak DNA marker format"
+       },
        {
                &psp_vecs,
                "psp",